package com.core.dao.mybatismysql;

import com.core.bean.Password;
import com.core.dao.IPasswordDao;
import com.core.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class PasswordDao implements IPasswordDao {
    @Override
    public int add(Password entity) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IPasswordDao iPasswordDao = session.getMapper(IPasswordDao.class);
        int add = iPasswordDao.add(entity);
        return add;
    }

    @Override
    public int remove(String id) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IPasswordDao iPasswordDao = session.getMapper(IPasswordDao.class);
        return iPasswordDao.remove(id);
    }

    @Override
    public int modify(Password entity) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IPasswordDao iPasswordDao = session.getMapper(IPasswordDao.class);
        return iPasswordDao.modify(entity);
    }

    @Override
    public Password findEntityById(String id) throws Exception {
        SqlSession session = MybatisUtils.getSession();
        IPasswordDao iPasswordDao = session.getMapper(IPasswordDao.class);
        Password entityById = iPasswordDao.findEntityById(id);
        return entityById;
    }

    @Override
    public List<Password> findOldPwd(String userId) {
        SqlSession session = MybatisUtils.getSession();
        IPasswordDao iPasswordDao = session.getMapper(IPasswordDao.class);
        return iPasswordDao.findOldPwd(userId);

    }
}
